home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6415 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  65 lines

  1. Path: news.rain.org!usenet
  2. From: "Guus Leeuw jr." <guusl@eiffel.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Please Please Help! - pointer notation
  5. Date: Sat, 24 Feb 1996 09:27:01 -0800
  6. Organization: Interactive Software Engineering Inc. http://www.eiffel.com/
  7. Message-ID: <312F4A65.794A5217@eiffel.com>
  8. References: <4gnlv9$1fh@news.mistral.co.uk>
  9. NNTP-Posting-Host: @outback.eiffel.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
  14.  
  15. Mike Barnard wrote:
  16. [snip snip]
  17. > I've read my C book. I've gotten th C FAQ. I've read the file
  18. > "ptrtutor.txt" a tutorial on pointers. But I havn't seen explained the
  19. > following. Can you help?
  20.  
  21. Probably time to throw at least the book and the `.txt' outta the window ;-)
  22.  
  23. > Sometimes when prototyping a function the function name is pre-fixed
  24. > by an asterisk. Why? What does it mean? This is a quote from the
  25. > pointer tutorial text by Ted Jensen...
  26.  
  27. Well, go from here:
  28. `int foo()' means `foo()' is a function returning an `int`. Right? Right.
  29. `char *str' means `str' is a pointer to `char'. Right? Right.
  30.  
  31. Let's mix the previous ones a bit up and we get:
  32. `char *bar()' means 'bar()' is a function returning a pointer to `char' ... !
  33.  
  34. (I'd rather write it like `char* bar()', but that's just my $0.02)
  35.  
  36. [snip snip]
  37. > Putting an asterisk before a variable name declares it as a pointer
  38. > variable. Putting one before the variable in use means you want to
  39. > access the data pointed to. Why is there sometimes an asterisk AFTER a
  40. > variable?
  41. > (And I can't find a quote at the moment...)
  42.  
  43. Let me give you one:
  44.  
  45. int main()
  46. {
  47.     int a, b;
  48.  
  49.     a = 4;
  50.     b = a * 3;    /* Now the asterisk's after a variable?? */
  51.  
  52.     return 1;
  53. }
  54.  
  55. Seriously, I never came across an asterisk after a variable that meant other than
  56. multiply. Might be my inexperience as well.
  57.  
  58. Hope the more serious parts might help,
  59.     Guus Leeuw jr.
  60.